//
//  L1DateHelper.h
//  Lesson401
//
//  Created by 徐盟 on 2023/3/17.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface XMMoment : NSObject

@property(nonatomic, strong) NSDate *date;
@property(nonatomic, assign) NSTimeInterval timestamp;

+(instancetype) moment;

- (instancetype)initWithDate:(NSDate *) date;
+(instancetype) momentWithDate:(NSDate *) date;

- (instancetype) initWithTimestamp:(NSTimeInterval) timestamp;
+(instancetype) momentWithTimestamp:(NSTimeInterval) timestap;

-(instancetype) initWIthString:(NSString *) str format:(NSString *)format;
+(instancetype) momentWithString:(NSString *) str  format:(NSString *)format;

-(void) addSecond:(NSInteger) second;
-(instancetype) createMomentByAddSecond:(NSInteger) second;
-(NSInteger) secondThenOther:(XMMoment *) otherMoment;
-(NSDateComponents *) componentsThenOther:(XMMoment *) otherMoment;



-(NSString *) foramt:(NSString*) format;

-(NSDate *) toDate;


@end

NS_ASSUME_NONNULL_END
